package edu.zut.main.thread;

public class ThreadYield {

    public static void main(String[] args) {
        YieldThread yieldThread = new YieldThread();
        new Thread(yieldThread,"小明").start();
        new Thread(yieldThread,"小花").start();
        new Thread(yieldThread,"小李").start();

    }

}

class YieldThread implements Runnable{

    @Override
    public void run() {
        System.out.println(Thread.currentThread().getName() + " begin....");
        //进行线程的礼让，让当前线程由运行转为就绪，让CPU重新选择线程执行
        Thread.yield();
        System.out.println(Thread.currentThread().getName() + " end.....");
    }
}


